<template>
  <div>
    <div class="mb20 lh1">提示内容</div>
    <div class="ks-row-middle mb20 lh1">
      <el-input
        type="textarea"
        v-model="text"
        style="width: 100%"
        :autosize="{ minRows: 3}"
        :maxlength="120"
        show-word-limit
        placeholder="请输入提示消息内容"
      />
    </div>
      <div class="ks-row-between mb20 lh1">
        <span style="width: 100px">确认回调</span>
        <el-switch v-model="showConfirm" disabled @change="changeMessageConfirm" />
      </div>
      <div class="ks-row-between mb20 lh1">
        <span style="width: 100px">取消回调</span>
        <el-switch v-model="showClose" @change="changeMessageCancel" />
      </div>

  </div>
</template>

<script>

import {getAllModalList} from '../../../utils/component'
export default {
  name: 'MessageBox',
  props: {
    eventItem: {}, // 需要逻辑编排的对象
    componentItem: {},
    block: {},
    workspace: {}
  },
  components: { },
  computed: {
    text: {
      get() {
        const text = this.block?.getFieldValue('MESSAGE_INPUT')
        return text || ''
      },
      set(val) {
        this.block.setFieldValue(val, 'MESSAGE_INPUT')
      }
    },
    messageConfirm: {
      get() {
        const count = this.block?.confirmCount_
        this.showConfirm = count ? true : false
        return count ? true : false
      },
      set(val) {
        this.block.confirmCount_ = val ? 1 : 0
        this.block.updateShape_()
      }
    },
    messageCancel: {
      get() {
        const count = this.block?.cancelCount_
        this.showClose = count ? true : false
        return count ? true : false
      },
      set(val) {
        this.block.cancelCount_ = val ? 1 : 0
        this.block.updateShape_()
      }
    }
  },
  data () {
    return {
      formData: {},
      modalList: [],
      showTitle: false,
      showConfirm: false,
      showClose: false
    }
  },
  watch: {
    'block': {
      handler() {
        this.getBlockData()
      },
      immediate: true
    }
  },
  methods: {
    getBlockData() {
      const confirmCount = this.block?.confirmCount_
      this.showConfirm = !!confirmCount
      this.messageConfirm = !!confirmCount

      const cancelCount = this.block?.cancelCount_
      this.showClose = !!cancelCount
      this.messageCancel = !!cancelCount
    },
    changeMessageConfirm(val){
      this.messageConfirm = val
    },
    changeMessageCancel(val){
      this.messageCancel = val
    },

    changeModal(val) {
    }
  }
}
</script>

<style scoped>

</style>
